<template>
	<view class="brand-showroom">
		<block v-if="show">
			<view class="brand-showroom-list">
				<view class="brand-showroom-item" v-for="(data,index) in list" :key="index"><image mode="widthFix" :src="data.image" @click="previewImgs(data.image)"></image></view>
			</view>
			<pt-loading-more v-if="isLoading"></pt-loading-more>
			<pt-nomore v-if="noMore && list.length"></pt-nomore>
			<pt-nothing 
				text="暂无展厅图" 
				:fixed="true" 
				v-if="noMore && !list.length" 
				icon="https://jiajudashi.oss-cn-shenzhen.aliyuncs.com/images/shop/icons/nothing.png?v=1">
			</pt-nothing>
		</block>
		<pt-loading></pt-loading>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				show: false,
				factory_id: '',
				list: [],
				page: 0,
				isLoading: false,
				noMore: false
			};
		},
		onLoad(options) {
			this.factory_id = options.factory_id
			this.init()
		},
		methods:{
			init(){
				this.$u.api.FactoryImage({factory_id: this.factory_id, type: 2,page: this.page}).then(res => {
					this.show = true
					this.isLoading = false
					if(res.datas.data.length){
						res.datas.data.forEach(item => {
							this.list.push(item)
						})
					}else{
						this.noMore = true
					}
				})
			},
			previewImgs(current){
				let urls = []
				this.list.forEach(item => {
					urls.push(item.image)
				})
				uni.previewImage({
					current: current,
					urls: urls
				})
			}
		},
		onReachBottom() {
			if(!this.noMore){
				this.page++
				this.isLoading = true
				this.init()
			}
		}
	}
</script>

<style lang="scss">
	.brand-showroom-list{
		padding: 1rpx 30rpx 30rpx;
		.brand-showroom-item{
			margin-top: 40rpx;
			image{
				width: 100%;
				border-radius: 8rpx;
			}
		}
	}
</style>
